package com.example;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.Parent;
import javafx.stage.Stage;
import java.io.IOException;
import java.sql.SQLException;

public class HelloApplication extends Application {
    @Override
    public void start(Stage stage) throws IOException {
        try {
            DatabaseUtil.initializeDatabase(); // 初始化数据库
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println("数据库初始化失败，应用程序无法启动。");
            Platform.exit(); // 正确退出应用程序
            return;
        }

        // 设置窗口的默认大小
        stage.setWidth(1000);
        stage.setHeight(700);

        FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("Login.fxml"));
        Parent root = fxmlLoader.load();
        LoginController controller = fxmlLoader.getController();
        controller.setPrimaryStage(stage);

        Scene scene = new Scene(root);
        stage.setTitle("学生成绩管理系统 - 登录");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
} 